﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

/// <summary>
/// Base class for all selection usercontrols.
/// </summary>
public abstract class ObjectSelection : ScrumWebControl
{
    /// <summary>
    /// Gets or sets a value indicating whether this instance is filter.
    /// </summary>
    /// <value><c>true</c> if this instance is filter; otherwise, <c>false</c>.</value>
    public bool IsFilter {get; set;}

    /// <summary>
    /// Returns top list item for filtername (e.g 'any role').
    /// </summary>
    /// <returns></returns>
    protected ListItem TopListItemForFilter(string filterName)
    {
        return TopListItemForFilter(filterName, "any");
    }

    /// <summary>
    /// Tops the list item for filtername and resource key.
    /// </summary>
    /// <param name="filterName">Name of the filter.</param>
    /// <param name="key">The key.</param>
    /// <returns></returns>
    protected ListItem TopListItemForFilter(string filterName, string key)
    {
        return new ListItem((string)GetGlobalResourceObject(filterName, key), "-1");
    }

    public enum ObjectSelectionType
    {
        Project,
        Release,
        Sprint,
        UserStory,
        Bli,
        Task,
        Role,
        Priority,
        WidgetType
    }

    public override bool ReadOnly
    {
        get
        {
            return base.ReadOnly;
        }
        set
        {
            (this.webControl as DropDownList).Enabled = !value;
            base.ReadOnly = value;
        }
    }
}
